.PHONY: application
application:
	goctl api format --dir src/api/

	goctl api go \
		--api src/api/application.api \
		--home src/util/tpl \
		--dir src

	CGO_ENABLED=0 \
	GO111MODULE=on \
	go build -v -o bin/application src/application.go

.PHONY: modelc
modelc:
	goctl model mysql ddl \
		--src ./src/internal/sql/$(TABLE).sql \
		--database application \
		--home src/util/tpl \
		--dir ./src/internal/model \
		--cache

.PHONY: model
model:
	goctl model mysql ddl \
		--src ./src/internal/sql/$(TABLE).sql \
		--database application \
		--home src/util/tpl \
		--dir ./src/internal/model

.PHONY: release
release:
	rm -rf ./release/*

	CGO_ENABLED=0 \
	GO111MODULE=on \
	GOOS=linux \
	GOARCH=amd64 \
	go build -v -o release/application src/application.go

	cp src/etc/application.yaml ./release/

.PHONY: test
test:
	rm -rf ./test/*

	CGO_ENABLED=0 \
	GO111MODULE=on \
	GOOS=linux \
	GOARCH=amd64 \
	go build -v -o test/application src/application.go

	cp src/etc/application-test.yaml ./test/

.PHONY: swagger
swagger:
	goctl api plugin \
		--plugin goctl-swagger="swagger -filename application.json" \
		--api ./src/api/application.api \
		--dir .

.PHONY: ts
ts:
	goctl api ts --api ./src/api/application.api --dir .
